---
--GamersArmy.net Hud code 
--TTT GA mod
---

--Lets do this post init so we can hope we have all the ents spawned right...
function timeToStr2( time )
	local tmp = time
	local s = tmp % 60
	tmp = math.floor( tmp / 60 )
	local m = tmp % 60
	tmp = math.floor( tmp / 60 )
	local h = tmp % 24
	tmp = math.floor( tmp / 24 )
	local d = tmp % 7
	local w = math.floor( tmp / 7 )
    if w != 0 then
	return string.format( "%02iw %id %02ih %02im %02is", w, d, h, m, s )
	elseif d != 0 then
	return string.format( "%id %02ih %02im %02is", d, h, m, s )
	elseif h != 0 then
	return string.format( "%02ih %02im %02is", h, m, s )
	else
	return string.format( "%02im %02is", m, s )
	end
end

function ga_post()
    ply = LocalPlayer()
    plyname = ply:GetName()
	hook.Add("HUDPaint", "GaHud", ga_hud)
	--we are going to add a refresh becuase it seems that it needs to be resynced every now so offten... 
	timer.Create("HudRefresh", 10, 0, ga_hud)
	--This is to resync money becuase it dose not always sync right on map changes. no clue wh
	RunConsoleCommand( "resync" )
	--RunConsoleCommand( "timecrap" )
end

--ply = LocalPlayer()
--plyname = ply:GetName()
--hook.Add("HUDPaint", "GaHud", ga_hud)
function ga_hud()
    ply = LocalPlayer()
	plyname = ply:GetName()
    ttime = timeToStr2( LocalPlayer():GetUTimeTotalTime() )
	local money = ply:GetNWInt("money")
	local hudmodle = gamodnamelocal[ply:GetNWInt("model")]
	draw.SimpleText("GamersArmy.net V0.09", "TargetID", ScrW() - 100, ScrH() - 30, Color(210,60,0,255), TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER)
	draw.SimpleText("Press F3 for GA Menu", "TargetID", ScrW() - 100, ScrH() - 15, Color(255,0,0,255), TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER)
	--draw.SimpleText("Playing as: ".. plyname, "TargetID", ScrW() - 20, ScrH() / 50 , Color(200,255,250,255), TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER)
	draw.SimpleText("GA Money: $".. money, "TargetID", ScrW() - 20, ScrH() / 50 , Color(255,255,144,255), TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER)
	--draw.SimpleText("Your model is set to : ".. hudmodle, "TargetID", ScrW() - 20, ScrH() / 15 , Color(255,255,144,255), TEXT_ALIGN_RIGHT, TEXT_ALIGN_CENTER)
	draw.SimpleText("Time on server: "..ttime , "TargetID", ScrW() / 35, ScrH() / 50 , Color(255,255,144,255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
end 
hook.Add( "InitPostEntity", "GaPost", ga_post) 




print("Loaded GA HUD")